{	Problem: http://codeforces.ru/problemset/problem/35/A
	Verdict: Accepted
}
var a,b,k:longint;
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(k);
read(a,b);
if a=k then k:=b else
if b=k then k:=a;
read(a,b);
if a=k then k:=b else
if b=k then k:=a;
read(a,b);
if a=k then k:=b else
if b=k then k:=a;
write(k);
end.